package com.wakala.employment.fragment.other;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.leaf.library.StatusBarUtil;
import com.wakala.employment.R;
import com.wakala.employment.core.BaseFragment;
import com.wakala.employment.core.webview.AgentWebFragment;
import com.wakala.employment.core.webview.XPageWebViewFragment;
import com.wakala.employment.databinding.FragmentPrivacyPolicyBinding;
import com.wakala.employment.utils.Utils;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.actionbar.TitleBar;
import com.xuexiang.xui.widget.textview.supertextview.SuperTextView;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link PrivacyPolicyFragment#} factory method to
 * create an instance of this fragment.
 */
@Page(anim = CoreAnim.none)
public class PrivacyPolicyFragment extends BaseFragment<FragmentPrivacyPolicyBinding> implements SuperTextView.OnSuperTextViewClickListener {


    private static final String PRIVACY_URL = "https://www.miaoyankeji.com/protocol/privacy_protocol.html";
    private static final String SERVICE_AGREEMENT_URL = "https://www.miaoyankeji.com/protocol/user_agreement.html";
    private static final String PERSONAL_BILL_URL = "https://www.miaoyankeji.com/protocol/user_info_collection_bill.html";
    private static final String THREE_BILL_URL = "https://www.miaoyankeji.com/protocol/user_info_3rd_share_bill.html";
    public static final String REAL_NAME_AUTH_URL =  "https://www.miaoyankeji.com/protocol/user_real_name_auth.html";

    @NonNull
    @Override
    protected FragmentPrivacyPolicyBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentPrivacyPolicyBinding.inflate(inflater, container, attachToRoot);
    }

    @SuppressLint("UseCompatLoadingForDrawables")
    @Override
    protected TitleBar initTitle() {
        TitleBar titleBar = super.initTitle();
        titleBar.setTitle("隐私政策");
        titleBar.setTitleColor(R.color.black);
        titleBar.setLeftTextColor(R.color.black);
        titleBar.setLeftImageDrawable(getResources().getDrawable(R.drawable.icon_arrow_back));
        titleBar.setBackgroundResource(R.color.white);//设置标题栏背景
        StatusBarUtil.setDarkMode(requireActivity());
        //设置状态栏背景颜色，如果设置为 Color.TRANSPARENT 将会隐藏状态栏
        requireActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.white));
        return titleBar;
    }

    @Override
    protected void initListeners() {
        super.initListeners();
        //服务协议
        binding.menuServiceAgreement.setOnSuperTextViewClickListener(this);
        //隐私政策
        binding.menuPrivacy.setOnSuperTextViewClickListener(this);
        //个人信息收集清单
        binding.menuPersonalBill.setOnSuperTextViewClickListener(this);
        //第三方信息共享清单
        binding.menuThreeBill.setOnSuperTextViewClickListener(this);
    }

    @Override
    protected void initViews() {

    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public void onClick(SuperTextView superTextView) {
        int id = superTextView.getId();
        switch (id) {
            case R.id.menu_service_agreement:
                Utils.goWeb(getContext(), SERVICE_AGREEMENT_URL);
                break;
            case R.id.menu_privacy:
                Utils.goWeb(getContext(), PRIVACY_URL);
                break;
            case R.id.menu_personal_bill:
                Utils.goWeb(getContext(), PERSONAL_BILL_URL);
                break;
            case R.id.menu_three_bill:
                Utils.goWeb(getContext(), THREE_BILL_URL);
                break;
            default:
                break;
        }
    }
}